home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / coun.com / TESTCOUN.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1990-04-05  |  1.9 KB  |  72 lines

  1. program test;
  2. uses coun;
  3.  
  4. type
  5.     st1 = record
  6.       int: integer;
  7.       ch : array [1..2] of STRING;
  8.     end;
  9.     str = record
  10.         st1 : string[8];
  11.         st2 : String;
  12.         Int : Integer;
  13.         a1  : array [1..2] of byte;
  14.         st3 : String[24];
  15.         a2  : array [1..2] of st1;
  16.         ab  : array [1..5] of byte;
  17.     end;
  18.  
  19. const rmap : string = 's8s,4s24[2i[2s]]5'; {map of str record above}
  20.          {s8 is st1}
  21.          {s is st2}
  22.          {the comma seporates the s from the 4 so as not to confuse
  23.           it for a 4 byte string}
  24.          {4 is both the Int and the a1 array each being 2 bytes}
  25.          {s25 is st3}
  26.          {[2 start a2}
  27.          {b[2c] is st1}
  28.          {the last ] closes off a2}
  29.          {ab is 5 bytes}
  30.  
  31. var struct : str;
  32.     barray : array [1..100] of byte;
  33.     x : Integer;
  34.  
  35. begin
  36.     struct.st1 := 'carl';
  37.     struct.st2 := 'Franz';
  38.     struct.int := 5;
  39.     struct.a1[1] := 1;
  40.     struct.a1[2] := 2;
  41.     struct.st3 := 'String24';
  42.     struct.a2[1].int:= 3;
  43.     struct.a2[2].int:= 4;
  44.     struct.a2[1].ch[1] := 'carl';
  45.     struct.a2[1].ch[2] := 'Doug';
  46.     struct.a2[2].ch[1] := 'Lynette';
  47.     struct.a2[2].ch[2] := 'alex';
  48.     Struct.ab[1] := 1; Struct.ab[2] := 2;
  49.     Struct.ab[3] := 3; Struct.ab[4] := 4; Struct.ab[5] := 5;
  50.  
  51.     x := Compress(rmap,struct,barray);
  52.  
  53.     writeln('Before length is : ',sizeof(struct),'  after length is:',x);
  54.  
  55.     struct.st1 := ' ';
  56.     struct.st2 := ' ';
  57.     struct.int := 0;
  58.     struct.a1[1] := 0;
  59.     struct.a1[2] := 0;
  60.     struct.st3 := ' ';
  61.     struct.a2[1].int:= 0;
  62.     struct.a2[2].int:= 0;
  63.     struct.a2[1].ch[1] := ' ';
  64.     struct.a2[1].ch[2] := ' ';
  65.     struct.a2[2].ch[1] := ' ';
  66.     struct.a2[2].ch[2] := ' ';
  67.     Struct.ab[1] := 0; Struct.ab[2] := 0;
  68.     Struct.ab[3] := 3; Struct.ab[4] := 4; Struct.ab[5] := 5;
  69.  
  70.     UnCompress(rmap,barray,struct);
  71. end.
  72.